package com.lin.service.impl;


import com.lin.entity.Comments;
import com.lin.entity.DynamicEntity;
import com.lin.entity.User;
import com.lin.entity.dto.CommentDTO;
import com.lin.entity.vo.CommentVO;
import com.lin.mapper.BmsCommentMapper;
import com.lin.service.CommunityService.IBmsCommentService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


@Slf4j
@Service
public class IBmsCommentServiceImpl implements IBmsCommentService {
    @Autowired
    private BmsCommentMapper bmsCommentMapper;

    @Override
    public List<CommentVO> getCommentsByTopicID(Integer dynamicid) {
        return bmsCommentMapper.getCommentsByTopicID(dynamicid);
    }
    @Override
    public Comments create(CommentDTO dto, User user){
        Comments comment = Comments.builder()
                .userId(user.getUserId())
                .commentsText(dto.getContent())
                .dynamicId(dto.getDynamic_id())
                .time(LocalDateTime.now())
                .build();
        bmsCommentMapper.createcomment(comment);
        return comment;
    }
}
